package com.mzp.XbShop.service;

import com.mzp.XbShop.mapper.UserCartDao;
import com.mzp.XbShop.pojo.UserCart;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @Description user_cart 服务层
 * @author admin
 * @date 2021-04-20 10:01:19
*/
@Service
public class UserCartService {

	@Autowired
	private UserCartDao userCartDao;


    public List<Map<String,Object>> findByCartId(String userid) {
        return userCartDao.findByCartId(userid);
    }

    public UserCart exits(String goodsid, String userid) {
        return userCartDao.exits(goodsid,userid);
    }

    public Integer addCart(String goodsid, String userid, Integer goodstotal) {
        UserCart userCart = new UserCart();
        userCart.setGoodsid(goodsid);
        userCart.setUserid(userid);
        userCart.setGoodstotal(goodstotal);
        userCart.setIdDel("0");
        userCart.setIsin(true);
        userCart.setPayStatus("0");
        return userCartDao.insert(userCart);
    }

    public void deleteCar(String goodsid, String userid) {
        userCartDao.deleteCar(goodsid,userid);
    }

    public Integer updateCart(String goodsid, String userid, Integer goodstotal) {
        return userCartDao.updateCart(goodsid,userid,goodstotal);
    }

    public List<Map<String,Object>> findByCartIdAndWaitPay(String userid) {
        return userCartDao.findByCartIdAndWaitPay(userid);
    }

    public void deleteWaitCar(String id, String userid) {
        userCartDao.deleteWaitCar(id,userid);
    }

    public void subOrder(String goodsid, String userid, String goodstotal) {
        userCartDao.subOrder(goodsid,userid,goodstotal);
    }
}
